package com.jr.service.impl;

import com.jr.dao.AddressDao;
import com.jr.dao.impl.AddressDaoImpl;
import com.jr.entity.Address;
import com.jr.service.AddressService;

import java.util.List;

public class AddressServiceImpl implements AddressService {
    private AddressDao addressDao = new AddressDaoImpl();

    /**
     * 新增地址
     * @param address
     * @return int类型 大于1表示新增成功
     * @throws Exception
     */
    @Override
    public int addAddress(Address address) throws Exception {
        return addressDao.addAddress(address);
    }

    /**
     * 根据企业查询相关地址
     * @param enterpriseId 企业id
     * @return
     * @throws Exception
     */
    @Override
    public List<Address> listAllAddress(Integer enterpriseId) throws Exception {
        return addressDao.getAddress(enterpriseId);
    }

    /**
     * 根据id更新Exist  用作假删除地址
     * @param addressId 地址的id
     * @return 大于0表示更新成功
     * @throws Exception
     */
    @Override
    public int updateAddressExist(Integer addressId) throws Exception {
        return addressDao.updateAddressExist(addressId);
    }

    /**
     * 根据id更新地址
     * @param address
     * @return 大于0表示更新成功
     * @throws Exception
     */
    @Override
    public int updateAddressById(Address address) throws Exception {
        return addressDao.saveAddressById(address);
    }

    /**
     * 根据id设置地址默认值
     * @param addressId
     * @return
     * @throws Exception
     */
    @Override
    public int setAddressDefaultById(Integer addressId) throws Exception {
        return addressDao.setAddressDefaultById(addressId);
    }

    /**
     * 将所有的默认值改为普通
     * @return
     * @throws Exception
     */
    @Override
    public int setAllAddressDefault() throws Exception {
        return addressDao.setAllAddressDefault();
    }


}
